<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>职位管理</el-breadcrumb-item>
      <el-breadcrumb-item>修改职位</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区域 -->
    <el-card>
      <el-form ref="jobform" label-width="80px" size="mini" :model="jobform">

        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="职位名称:">
              <el-input v-model="jobform.name"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <el-form-item label="职位备注:">
              <el-input v-model="jobform.remark"></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="2">
            <el-form-item>
              <el-button type="primary" size="small" @click="jobeditbtn"
                >修改</el-button
              >
            </el-form-item>
          </el-col>
          <el-col :span="2">
            <el-form-item>
              <!-- 返回原来的页面 -->
              <el-button type="warning" size="small" @click="goback"
                >返回</el-button
              >
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
  </div>
</template>

<script>
export default {
  created() {
    this.getEmployeeImformation(this.$route.query.id);
  },
  data() {
    return {
        jobform: {}
    }
  },
  methods: {
    getEmployeeImformation(id){
        this.$http.post(`/job/findId/${id}`).then(resp =>{
            console.log(resp)
            if(resp.data.flag){
                this.jobform=resp.data.data
            }else{
                console.log("获取职位信息失败")
            }
        })
    },
    async jobeditbtn() {

      console.log(this.jobform);
      const { data: res } = await this.$http.post("/job/edit", this.jobform);
      if (res.code == 200) {
        this.$message.success(res.message);
      } else {
        this.$message.error(res.message);
      }
      this.$router.push("/job");
    },
    goback() {
      window.history.back();
    },
  },
};
</script>

<style></style>
